<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <input type="hidden" name="planId" id="planId" th:value="${planId}"/>
                    <input type="hidden" name="roleKey" id="roleKey" th:value="${role}"/>
                    <ul>
                        <li>
                            订单id：<input type="text" name="orderId" id="orderId"/>
                        </li>
                        <li>
                            计划类型：
                            <select name="moneyType" th:with="type=${@dict.getType('sys_plan_type_item')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <li>
                            计划状态：
                            <select name="status" th:with="type=${@dict.getType('hatchet_plan_item_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <li>
                            通道名称：<input type="text" name="acqName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">

            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:planItem:export">-->
            <!--<i class="fa fa-download"></i> 导出-->
            <!--</a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:plan:edit')}]];
    var prefix = ctx + "system/planItemNew";
    var prefix1 = ctx + "system/paymentOrder";
    var datas = [[${@dict.getType('hatchet_plan_item_status')}]];
    var datas1 = [[${@dict.getType('sys_plan_type_item')}]];

    $(function () {
        var options = {
            url: prefix + "/list",
            exportUrl: prefix + "/export",
            queryParams: queryParams,
            modalName: "小计划",
            sortName: "planTime",
            sortOrder: "asc",
            search: false,
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'planId',
                    align: 'center',
                    title: '大计划ID',

                },

                {
                    field: 'merchantName',
                    align: 'center',
                    title: '用户名称',
                    formatter: function (value, row, index) {
                        return "<strong style='color:royalblue's>" + value + "</strong>";
                    }
                },
                {
                    field: 'merchantPhone',
                    align: 'center',
                    title: '手机号',

                },
                {
                    field: 'cardName',
                    align: 'center',
                    title: '银行名称',

                    formatter: function (value, row, index) {
                        return "<strong style='color: red's>" + value + "</strong>";
                    }
                },
                {
                    field: 'cardNumber',
                    align: 'center',
                    title: '卡号',
                    formatter: function (value, row, index) {
                        if ($("#roleKey").val() == "agent"){
                            if(value!=null&&value!=""){
                                var value1=value.substring(0,4);
                                var value2=value.substring(value.length-4,value.length);
                                return "<span  >" + value1+'********'+value2 + "</span>";
                            }
                        }else{
                            return "<span  >" + value + "</span>";
                        }
                    }

                },

                {
                    field: 'orderId',
                    align: 'center',
                    title: '订单id',
                    formatter: function (value, row, index) {
                        if (value != "" && value != null) {
                            var role= $("#roleKey").val();
                            if (role == "admin" || role == "cs") {
                                return '<a href="#" onclick="detail(\'' + row.orderId + '\')">' + value + '</a>';
                            }else{
                                return value;
                            }
                        }
                    }
                },
                {
                    field: 'moneyType',
                    align: 'center',
                    title: '计划类型',

                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas1, value);
                    }
                },
                {
                    field: 'status',
                    align: 'center',
                    title: '状态',

                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }

                },
                {
                    field: 'groupNumber',
                    align: 'center',
                    title: '组数',
                },

                {
                    field: 'money',
                    align: 'center',
                    title: '付款金额',

                    formatter: function (value, row, index) {
                        return "<strong style='color:red's>" + value + "</strong>";
                    }
                },
                {
                    field: 'acqName',
                    align: 'center',
                    title: '通道名称',
                    formatter: function (value, row, index) {
                        if (value != null && value != "") {
                            return "<strong style='color: #1E0FBE's>" + value + "</strong>";
                        }
                        return ""
                    }
                },
                {
                    field: 'planTime',
                    align: 'center',
                    title: '执行时间',

                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        var role= $("#roleKey").val();
                        if (role == "admin" || role == "cs") {
                            if(row.status!=3){
                                actions.push('<a class="btn btn-danger btn-xs ' +editFlag+ '" href="#" onclick="updatePlanTime(\'' + row.id + '\')">设置执行时间</a>')
                            }
                        }
                        return actions.join('');
                    }
                },


            ]
        };
        $.table.init(options);
    });


    //设置执行时间
    function updatePlanTime(id) {
        var url = prefix + '/edit/' + id;

        $.modal.open("修改执行时间", url);

    }

    function queryParams(params) {
        return {
            planId: $("#planId").val(),
            pageSize: params.limit,
            pageNum: params.offset / params.limit + 1,
            searchValue: params.search,
            orderByColumn: params.sort,
            isAsc: params.order
        };
    }

    //订单详情
    function detail(id) {
        var url = prefix1 + '/detail/' + id;
        createMenuItem(url, "查看详情");
    }
</script>
</body>
</html>